﻿@using CodeGenerator
@using RazorLight
@using BXJG.Common;
@inherits TemplatePage<ExecuteContext>
@{
    DisableEncoding = true;//禁止html编码，因为我们是做代码生成器
}
using Abp.Application.Services.Dto;
using System.ComponentModel;
using BXJG.Common.Contracts;
using System.ComponentModel.DataAnnotations;
@if(Model.Model.IsTree)
{
@:using BXJG.Utils.Application.Share.GeneralTree;    
}
using @Model.Model.CoreShareNamespace;

namespace @(Model.Model.ApplicationShareNamespace)
{
    /// <summary>
    /// 各应用编辑 @(Model.Model.DisplayName) 的数据模型
    ///</summary>
    public partial class @(Model.Model.EditDtoName) : @(Model.Model.IsTree ? $"GeneralTreeNodeEditBaseDto" : (Model.Model.PrimaryField.CSharpType == "int" ? "EntityDto" : $"EntityDto<{Model.Model.PrimaryField.CSharpType}>"))
    {
@foreach (var field in Model.Model.NormalFields){<text>
        /// <summary>
        /// @(field.DisplayName)
        ///</summary>
        [Display(Name="@(field.DisplayName)")]
    @if(field.IsRequired){
        @:[Required]
    }
    @if(field.CSharpTypeIsNumber && field.NumberMin.HasValue&& field.NumberMin.HasValue){
        //若出现空字符串，最终生成的结果会报错，获取最终MaxValue MinValue也麻烦，索性不处理了
        if(field.NumberMax!=default && field.NumberMin!=default)
        { 
            @:[Range(typeof(@field.CSharpType), "@field.NumberMin", "@field.NumberMax")]
        }
    }
    @if(field.Length>0){
        @:[StringLength(@field.CoreShareConstsMaxLength)]
    }
        public @(field.CSharpTypeNullable) @field.Name { get; set; } @* @(field.DefaultValue.IsNotNullOrWhiteSpaceBXJG()?$" = { field.DefaultValueProgram };":string.Empty) *@
</text>}
    }
}